<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

//api路由
Route::namespace('Api')->group(function(){
    //用户模块
    Route::prefix('user')->namespace('User')->group(function(){
        #用户类
        Route::post('login','UserBaseController@do_login');#登录
        Route::post('reg','UserBaseController@do_reg');#注册
        Route::post('getUserInfo','UCenterController@getUserInfo');#获取用户信息
        Route::post('get_sms_code','UserBaseController@get_sms_code');#获取验证码
        Route::post('check_sms_code','UserBaseController@check_sms_code');#检测验证码
        Route::post('forget_password','UserBaseController@forget_password');#忘记密码
        Route::post('myUCenter','UCenterController@myUCenter');#
        Route::post('myInvitation','UCenterController@myInvitation');#我的推荐
        Route::post('myDistributionCenter','UCenterController@myDistributionCenter');#分销中心
        Route::post('submitFeedBack','UCenterController@submitFeedBack');#提交用户反馈
        Route::post('modifyUser','UCenterController@modifyUser');#修改用户信息
        Route::post('getJsSdkConfig','UCenterController@getJsSdkConfig');#修改用户信息
        Route::post('getBalance','UCenterController@getBalance');#收支记录




        #收货地址类
        Route::post('addAddress','UCenterController@addAddress');#新增地址
        Route::post('editAddress','UCenterController@editAddress');#修改地址
        Route::post('addressList','UCenterController@addressList');#地址列表
        Route::post('delAddress','UCenterController@delAddress');#删除地址
        Route::post('getAddressByAddressId','UCenterController@getAddressByAddressId');#删除地址
        Route::post('setDefaultAddress','UCenterController@setDefaultAddress');#设置默认地址
        Route::get('defaultAddress','UCenterController@defaultAddress');#用于下单也默认地址的获取
		Route::post('rechargeCommissionByUid','ReBateController@rechargeCommissionByUid');#代充值信息
        #提现模块
          #1.申请提现
        Route::post('apply_cash','CashController@apply_cash');
        #合伙人
          #1.合伙人申请
        Route::post('apply_coperate','CoperateController@apply_coperate');
        Route::post('bindVipCard','UCenterController@bindVipCard');#代绑卡

        Route::post('addComment','UCenterController@addComment');#立即评论
        Route::post('myComment','UCenterController@myComment');#我的评论
        Route::get('aboutus','UCenterController@aboutus');#关于我们
        Route::post('getUploadToken','UCenterController@getUploadToken');#关于我们
    });

    #购物车
    Route::prefix('cart')->namespace('User')->group(function(){
        #添加购物车
        Route::post('add','CartController@add_cart');
        #购物车列表
        Route::get('list','CartController@cart_list');
        #购物车数据的更新
        Route::post('update','CartController@updateCart');
        #购物车结算以及立即购买进入确认订单页面的统一调用接口
        Route::post('buynow','CartController@buyNow');
        #购物车删除
        Route::post('delete','CartController@delete');
        #购物车数量增加
        Route::post('increment','CartController@increment');
        #购物车数量删除
        Route::post('decrement','CartController@decrement');
    });

    #订单
    Route::prefix('order')->namespace('Order')->group(function(){
        #添加购物车
        Route::post('createRechargeOrder','RechargeOrderController@createRechargeOrder');
        Route::post('RechargeOrderController','RechargeOrderController@createRechargeOrder');
        Route::post('NotifyByRecharge','NotifyController@NotifyByRecharge');
        Route::post('testBalance','NotifyController@testBalance');

    });

    //首页模块
    Route::group(['namespace'=>'Main','prefix'=>'main'],function (){
        #轮播获取
        Route::get('banner_list','MainController@banner');
        Route::get('get_cate','MainController@getTopCate');
        Route::get('get_cates','MainController@getCates');
        Route::get('get_hot_goods','MainController@getGoods');
        Route::get('get_goods','MainController@getGoods');
        Route::post('search_goods','MainController@serachGoods');


        #商品详情
            #商品详情的获取
            Route::get('get_goods_mess','MainController@getBaseGoodsMessage');
            #获取某个spu商品的属性和属性值列表
            Route::get('get_goods_props','MainController@getGoodFormat');
            #选择属性值返回sku商品信息
            Route::post('get_sku_by_props','MainController@getSkuByPropsAndVal');
            #商品评论
            Route::get('get_goods_comment','MainController@getGoodComment');
        #优惠券
            #1.系统发放的优惠券列表(每个人可见 可自由领取)
        Route::get('sys_coupon_list','CouponController@sys_coupon_list');
            #2.领取优惠券
        Route::post('receive_coupon','CouponController@receive_coupon');
            #3.用户已经领取的优惠券列表
        Route::get('user_coupon','CouponController@user_coupon');
        # 获取个人评论
        Route::post('user_comment','MainController@getMyComment');
        #支付页面
        Route::post('topay','PayController@payByWechat');
        #支付回调地址
        Route::match(['post','get'],'notify','PayController@notify')->name('payment.wechat.notify');

        #获取openid
        Route::get('getopenid','PayController@getOpenid');

        #确认下单页面
//        Route::post('makeOrder','OrderController@toOrder');

        #个人订单查询页面
        Route::post('userOrder','OrderController@userOrder');

        #订单详情页面
        Route::post('orderDetail','OrderController@orderDetail');

        #生成订单正式方法
        Route::post('makeOrder','OrderController@testorder');

        #取消订单
        Route::match(['post'],'cancelOrder','OrderController@cancel');

        #申请退款
        Route::match(['post'],'applyRefund','OrderController@apply_refund');

        #确认收货
        Route::match(['post'],'confirmShip','OrderController@confirm_ship');

        #申请退货
        Route::post('apply_shipback','OrderController@apply_shipback');

        #支付页面
        Route::match(['get','post'],'testpay','PayController@WxPay');

        #生成订单正式方法
        Route::post('order_num','OrderController@order_num');

        #支付参数的获取(用户已经绑定open_id的情况下)
        Route::match(['post'],'payParams','PayController@payParams');
        Route::match(['post'],'getUserWxInfo','PayController@getUserWxInfo');
        #仅仅用于前端获取openId
        Route::match(['get'],'wap_open_id','PayController@wap_open_id');
        Route::match(['post'],'balancePayment','OrderController@balancePayment');#余额支付
        Route::match(['post'],'getPreferGoods','MainController@getPreferGoods');#推荐商品

        #注册时重定向到前端附上openId
        Route::get('wap_regist_get_open_id','PayController@wap_regist_get_open_id');

    });

    Route::prefix('hotel')->namespace('Hotel')->group(function(){
        Route::get('dashboard','DashboardController@data');#酒店首页dashboard
        Route::get('loglist','TransactionLogsController@loglist');//流水列表
        Route::post('apply','HotelOwnerController@api_apply'); //酒店申请入驻
        Route::get('list','HotelOwnerController@hotel_list');//酒店列表
        Route::post('detect_owner','HotelOwnerController@detect_owner');//检查该用户是否是有效的酒店管理员(在owner_apply表中是否已经完全入驻至少一家酒店)

        #以下用于后台接口
        Route::post('hotel_goods_list','HotelGoodsController@hotel_goods_list');//酒店商品库存列表
        Route::post('update_stock','HotelGoodsController@update_stock');//更新酒店商品库存接口
        Route::post('delete_goods','HotelGoodsController@delete_goods');//酒店商品的删除
        Route::post('update_stock_specially','HotelGoodsController@update_stock_specially');//酒店商品库存的特殊情况的更新
    });
    Route::prefix('hotel')->namespace('Main')->group(function(){
        Route::get('orderlist','OrderController@hotel_owner_order');//获取酒店订单列表

    });

    Route::prefix('hotel')->namespace('System')->group(function(){
        Route::get('config','SystemController@getconfig');#酒店首页dashboard
    });


    Route::prefix('machine')->namespace('Machine')->group(function(){
        Route::post('getMachineGoods','MachineAndGoodsController@getMachineGoods');#机器下面的商品列表
        Route::post('delMachineFromHotel','MachineAndGoodsController@delMachineFromHotel');#从酒店下面删除机器
        Route::post('getHotelList','MachineAndGoodsController@getHotelList');
        Route::post('searchMachine','MachineAndGoodsController@searchMachine');#搜索机器
        Route::post('saveMachine','MachineAndGoodsController@saveMachine'); //设备的添加
        Route::post('settingBoxStatus','MachineAndGoodsController@settingBoxStatus'); //设备的有货无货状态更新
    });













});
